<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>

  <body>
    <script>
      function createXHR() {
        var xhr;
        if (window.XMLHttpRequest) {
          xhr = new XMLHttpRequest();
        } else {
          xhr = new ActiveXObjext('Microsoft.XMLHttp');
        }
        return xhr;
      }
      //第一步：创建XMLHttpReques对象
      var ajax = createXHR();
      console.log(ajax.readyState);

      //第二步：创建请求
      ajax.open('get', 'https://cnodejs.org/api/v1/topics', true);
      console.log(ajax.readyState);
      
      //测试链接及测试API参见如下
      //https://cnodejs.org/
      //https://cnodejs.org/api

      //https://www.juhe.cn
      //https://www.juhe.cn/docs

    </script>
  </body>
</html>
